function scheduleRotation(peopleArray) {
    const rotationArray = [];
    const categories = peopleArray.length;
    let maxCycle = Math.max(...peopleArray.map(category => category.length));
    const lcm = calculateLCM(peopleArray.map(category => category.length));
  
    // 补充人员
    for (let i = 0; i < categories; i++) {
      const categoryPeople = peopleArray[i];
      if (categoryPeople.length < lcm) {
        const additionalPeople = categoryPeople.slice();
        while (additionalPeople.length < lcm) {
          additionalPeople.push(...categoryPeople);
        }
        peopleArray[i] = additionalPeople;
      }
    }
  
    // 安排轮班
    for (let i = 0; i < lcm; i++) {
      const dayPeople = [];
      for (let j = 0; j < categories; j++) {
        const categoryPeople = peopleArray[j];
        dayPeople.push(categoryPeople[i % categoryPeople.length]);
      }
      rotationArray.push(dayPeople);
    }
  
    return rotationArray;
  }
  
  // 计算最小公倍数
  function calculateLCM(arr) {
    let lcm = arr[0];
    for (let i = 1; i < arr.length; i++) {
      lcm = (lcm * arr[i]) / calculateGCD(lcm, arr[i]);
    }
    return lcm;
  }
  
  // 计算最大公约数
  function calculateGCD(a, b) {
    if (b === 0) {
      return a;
    }
    return calculateGCD(b, a % b);
  }
  
  // 示例用法
  const category1 = ["A1", "A2", "A3", "A4","A5"];
  const category2 = ["B1", "B2", "B3"];
  const category3 = ["C1", "C2","C3"];
  
  const peopleArray = [category1, category2, category3];
  const rotationArray = scheduleRotation(peopleArray);
  
  console.log(rotationArray);